﻿using System;

namespace FirstFloor.Documents.Pdf
{
    /// <summary>
    /// Represent a token.
    /// </summary>
    internal struct Token
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Token"/> struct.
        /// </summary>
        /// <param name="type">The type.</param>
        public Token(TokenType type)
            : this()
        {
            this.Type = type;
            this.Value = null;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Token"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="value">The value.</param>
        public Token(TokenType type, string value)
            : this()
        {
            this.Type = type;
            this.Value = value;
        }

        /// <summary>
        /// Gets the token type.
        /// </summary>
        /// <value>The type.</value>
        public TokenType Type { get; private set; }
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <value>The value.</value>
        public string Value { get; private set; }

        /// <summary>
        /// Returns the fully qualified type name of this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> containing a fully qualified type name.
        /// </returns>
        public override string ToString()
        {
            if (this.Value == null) {
                return string.Format("{0}", this.Type);
            }
            else {
                return string.Format("{0} {1}", this.Type, this.Value);
            }
        }
    }
}
